Public Class ProvvPrat
    Inherits Connessione

    Private _id As String
    Private _idPrat As String
    Private _tipo As Int16
    Private _delibera As String
    Private _annotazioni As String
    Private _data As String

    Public Property id() As String
        Get
            Return _id
        End Get
        Set(ByVal Value As String)
            _id = Value
        End Set
    End Property
    Public Property idPrat() As String
        Get
            Return _idPrat
        End Get
        Set(ByVal Value As String)
            _idPrat = Value
        End Set
    End Property
    Public Property tipo() As Int16
        Get
            Return _tipo
        End Get
        Set(ByVal Value As Int16)
            _tipo = Value
        End Set
    End Property
    Public Property delibera() As String
        Get
            Return _delibera
        End Get
        Set(ByVal Value As String)
            _delibera = Value
        End Set
    End Property
    Public Property data() As String
        Get
            Return _data
        End Get
        Set(ByVal Value As String)
            _data = Value
        End Set
    End Property
    Public Property annotazioni() As String
        Get
            Return _annotazioni
        End Get
        Set(ByVal Value As String)
            _annotazioni = Value
        End Set
    End Property

    Public Sub carica()
        Dim dr As DataRow = getDataTable("select tipo_provv,delibera, annotazioni, convert(char(10),data,103) as data from provvedimenti where id =" & _id).Rows(0)
        _tipo = dr("tipo_provv")
        _delibera = dr("delibera")
        _annotazioni = dr("annotazioni")
        _data = Utility.sNull(dr("data"))

    End Sub

    Public Sub inserisci()
        Dim sql As String = " insert into provvedimenti (id_prat, tipo_provv, delibera, data, annotazioni, utente) values (" & _
                            "@idPrat, @tipo, @delibera, @data, @annotazioni, @utente)"

        Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, getConnection)

        cmd.Parameters.Add("@idPrat", _idPrat)
        cmd.Parameters.Add("@tipo", _tipo)
        cmd.Parameters.Add("@delibera", _delibera)
        cmd.Parameters.Add("@data", IIf(_data = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_data)))
        cmd.Parameters.Add("@annotazioni", _annotazioni)
        cmd.Parameters.Add("@Utente", System.Security.Principal.WindowsIdentity.GetCurrent.Name)

        cmd.ExecuteNonQuery()
        cmd.Connection.Close()

    End Sub

    Public Sub aggiorna()
        Dim sql As String = " update provvedimenti set tipo_provv=@tipo, delibera=@delibera, data=@data, " & _
                 " annotazioni=@annotazioni, utente=@utente where id=" & _id

        Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, getConnection)

        cmd.Parameters.Add("@tipo", _tipo)
        cmd.Parameters.Add("@delibera", _delibera)
        cmd.Parameters.Add("@data", IIf(_data = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_data)))
        cmd.Parameters.Add("@annotazioni", _annotazioni)
        cmd.Parameters.Add("@Utente", System.Security.Principal.WindowsIdentity.GetCurrent.Name)

        cmd.ExecuteNonQuery()
        cmd.Connection.Close()
    End Sub

    Public Sub elimina()
        eseguiSql("delete from provvedimenti where id=" & _id)
    End Sub
End Class

Public Class SospPrat
    Inherits Connessione

    Private _id As String
    Private _idPrat As String
    Private _tipo As String
    Private _motivo As String
    Private _dataInizio As String
    Private _dataFine As String
    Private _tot As String

    Public Property tot() As String
        Get
            Return _tot
        End Get
        Set(ByVal Value As String)
            _tot = Value
        End Set
    End Property
    Public Property id() As String
        Get
            Return _id
        End Get
        Set(ByVal Value As String)
            _id = Value
        End Set
    End Property
    Public Property idPrat() As String
        Get
            Return _idPrat
        End Get
        Set(ByVal Value As String)
            _idPrat = Value
        End Set
    End Property
    Public Property tipo() As String
        Get
            Return _tipo
        End Get
        Set(ByVal Value As String)
            _tipo = Value
        End Set
    End Property
    Public Property motivo() As String
        Get
            Return _motivo
        End Get
        Set(ByVal Value As String)
            _motivo = Value
        End Set
    End Property
    Public Property dataInizio() As String
        Get
            Return _dataInizio
        End Get
        Set(ByVal Value As String)
            _dataInizio = Value
        End Set
    End Property
    Public Property dataFine() As String
        Get
            Return _dataFine
        End Get
        Set(ByVal Value As String)
            _dataFine = Value
        End Set
    End Property

    Public Sub carica()
        Dim dr As DataRow = getDataTable("select tipo,motivo,tot, convert(char(10),dataInizio,103) as dataInizio, convert(char(10),dataFine,103) as dataFine from sospensioni where id =" & _id).Rows(0)
        _tipo = Utility.sNull(dr("tipo"))
        _motivo = dr("motivo")
        _dataInizio = Utility.sNull(dr("dataInizio"))
        _dataFine = Utility.sNull(dr("dataFine"))
        _tot = Utility.sNull(dr("tot"))

    End Sub

    Public Sub inserisci()
        Dim sql As String = " insert into sospensioni (id_prat, tipo, motivo, tot,  dataInizio, dataFine, utente) values (" & _
                            "@idPrat, @tipo, @motivo, @tot, @dataInizio, @dataFine, @utente)"

        Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, getConnection)

        cmd.Parameters.Add("@idPrat", _idPrat)
        cmd.Parameters.Add("@motivo", _motivo)
        cmd.Parameters.Add("@tipo", IIf(_tipo = "", SqlTypes.SqlInt16.Null, _tipo))
        cmd.Parameters.Add("@dataInizio", IIf(_dataInizio = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataInizio)))
        cmd.Parameters.Add("@dataFine", IIf(_dataFine = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataFine)))
        cmd.Parameters.Add("@tot", IIf(_tot = "", SqlTypes.SqlInt32.Null, _tot))
        cmd.Parameters.Add("@Utente", System.Security.Principal.WindowsIdentity.GetCurrent.Name)

        cmd.ExecuteNonQuery()
        cmd.Connection.Close()

    End Sub

    Public Sub aggiorna()
        Dim sql As String = " update sospensioni set tipo =@tipo, motivo = @motivo, tot=@tot, dataInizio =@dataInizio, dataFine =@dataFine, utente=@utente  where id=" & _id

        Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, getConnection)

        cmd.Parameters.Add("@motivo", _motivo)
        cmd.Parameters.Add("@tipo", IIf(_tipo = "", SqlTypes.SqlInt16.Null, _tipo))
        cmd.Parameters.Add("@dataInizio", IIf(_dataInizio = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataInizio)))
        cmd.Parameters.Add("@dataFine", IIf(_dataFine = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataFine)))
        cmd.Parameters.Add("@tot", IIf(_tot = "", SqlTypes.SqlInt32.Null, _tot))
        cmd.Parameters.Add("@Utente", System.Security.Principal.WindowsIdentity.GetCurrent.Name)

        cmd.ExecuteNonQuery()
        cmd.Connection.Close()
    End Sub

    Public Sub elimina()
        eseguiSql("delete from sospensioni where id=" & _id)
    End Sub


End Class

Public Class AtsPrat
    Inherits Connessione

    Private _id As String
    Private _idPrat As String
    Private _idDitta As String
    Private _nomeDitta As String
    Private _dataRichiesta As String
    Private _dataDel As String
    Private _numDel As String
    Private _stato As String
    Private _dataInizio As String
    Private _dataFine As String
    Private _tot As String
    Private _completato As Boolean
    Private _crediti As String
    Private _contratto As String

    Public Property crediti() As String
        Get
            Return _crediti
        End Get
        Set(ByVal Value As String)
            _crediti = Value
        End Set
    End Property
    Public Property tot() As String
        Get
            Return _tot
        End Get
        Set(ByVal Value As String)
            _tot = Value
        End Set
    End Property
    Public Property completato() As Boolean
        Get
            Return _completato
        End Get
        Set(ByVal Value As Boolean)
            _completato = Value
        End Set
    End Property
    Public Property contratto() As String
        Get
            Return _contratto
        End Get
        Set(ByVal Value As String)
            _contratto = Value
        End Set
    End Property
    Public Property id() As String
        Get
            Return _id
        End Get
        Set(ByVal Value As String)
            _id = Value
        End Set
    End Property
    Public Property idPrat() As String
        Get
            Return _idPrat
        End Get
        Set(ByVal Value As String)
            _idPrat = Value
        End Set
    End Property
    Public Property idDitta() As String
        Get
            Return _idDitta
        End Get
        Set(ByVal Value As String)
            _idDitta = Value
        End Set
    End Property
    Public Property nomeDitta() As String
        Get
            Return _nomeDitta
        End Get
        Set(ByVal Value As String)
            _nomeDitta = Value
        End Set
    End Property
    Public Property dataRichiesta() As String
        Get
            Return _dataRichiesta
        End Get
        Set(ByVal Value As String)
            _dataRichiesta = Value
        End Set
    End Property
    Public Property dataDel() As String
        Get
            Return _dataDel
        End Get
        Set(ByVal Value As String)
            _dataDel = Value
        End Set
    End Property
    Public Property numDel() As String
        Get
            Return _numDel
        End Get
        Set(ByVal Value As String)
            _numDel = Value
        End Set
    End Property
    Public Property stato() As String
        Get
            Return _stato
        End Get
        Set(ByVal Value As String)
            _stato = Value
        End Set
    End Property
    Public Property dataInizio() As String
        Get
            Return _dataInizio
        End Get
        Set(ByVal Value As String)
            _dataInizio = Value
        End Set
    End Property
    Public Property dataFine() As String
        Get
            Return _dataFine
        End Get
        Set(ByVal Value As String)
            _dataFine = Value
        End Set
    End Property



    Public Function calcolaCrediti() As String
        Dim objC As New cConfigura(False)
        Dim totG As Int16 = objC.conf.totalePraticantato
        Dim giorniDitta As Int16 = objC.conf.giorniDitta

        Dim rit As Int16
        _tot = IIf(Trim(_tot) <> "", _tot, 0)

        'ditta
        rit = (_tot * totG) \ giorniDitta

        If rit <> 0 Then
            Return rit
        Else
            Return ""
        End If

    End Function


    Public Sub carica()
        Dim dt As DataTable = getDataTable("select  AttSub.id_ditta, nomeDitta, convert(char(10),dataRichiesta, 103) as dataRichiesta, convert(char(10),dataDel, 103) as dataDel, numDel, stato, convert(char(10),data_Inizio, 103) as dataInizio,convert(char(10),data_Fine,103) as dataFine, contratto, tot, completato, crediti from attSub where AttSub.id =" & _id)
        If dt.Rows.Count > 0 Then
            Dim dr As DataRow = dt.Rows(0)
            '_id = dr("id")
            _idDitta = Utility.sNull(dr("id_ditta"))
            _nomeDitta = Utility.sNull(dr("nomeDitta"))
            _dataRichiesta = Utility.sNull(dr("dataRichiesta"))
            _dataDel = Utility.sNull(dr("datadel"))
            _numDel = Utility.sNull(dr("numDel"))
            _stato = dr("stato")
            _dataInizio = Utility.sNull(dr("dataInizio"))
            _dataFine = Utility.sNull(dr("dataFine"))
            _contratto = Utility.sNull(dr("contratto"))
            _tot = Utility.sNull(dr("tot"))
            _completato = Utility.sNull(dr("completato"))
            _crediti = Utility.sNull(dr("crediti"))
        End If


    End Sub

    Public Sub inserisci()
        Dim sql As String = " insert into attSub (id_prat, id_ditta, nomeDitta, dataRichiesta, dataDel, numDel, stato, data_Inizio, data_Fine,  utente, contratto, tot, completato, crediti) values (" & _
                            "@idPrat,@idDitta, @nomeDitta, @dataRichiesta, @dataDel, @numDel, @stato, @dataInizio, @dataFine,  @utente, @contratto, @tot, @completato, @crediti)"

        Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, getConnection)

        cmd.Parameters.Add("@idPrat", _idPrat)
        cmd.Parameters.Add("@idDitta", _idDitta)
        cmd.Parameters.Add("@nomeDitta", _nomeDitta)
        cmd.Parameters.Add("@dataRichiesta", IIf(_dataRichiesta = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataRichiesta)))
        cmd.Parameters.Add("@dataDel", IIf(_dataDel = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataDel)))
        cmd.Parameters.Add("@numDel", _numDel)
        cmd.Parameters.Add("@stato", _stato)
        cmd.Parameters.Add("@dataInizio", IIf(_dataInizio = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataInizio)))
        cmd.Parameters.Add("@dataFine", IIf(_dataFine = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataFine)))
        cmd.Parameters.Add("@tot", IIf(_tot = "", SqlTypes.SqlInt32.Null, _tot))
        cmd.Parameters.Add("@completato", _completato)
        cmd.Parameters.Add("@crediti", IIf(_crediti = "", SqlTypes.SqlInt32.Null, _crediti))
        cmd.Parameters.Add("@contratto", IIf(_contratto = "", SqlTypes.SqlInt16.Null, _contratto))
        cmd.Parameters.Add("@Utente", System.Security.Principal.WindowsIdentity.GetCurrent.Name)

        cmd.ExecuteNonQuery()
        cmd.Connection.Close()

    End Sub

    Public Sub aggiorna()
        Dim sql As String = " update attSub set id_ditta=@idDitta, nomeDitta=@nomeDitta, dataRichiesta=@dataRichiesta, dataDel=@dataDel, numDel=@numDel, stato=@stato, data_Inizio =@dataInizio, data_Fine =@dataFine, " & _
                " utente=@utente, tot=@tot, completato=@completato, crediti=@crediti, contratto=@contratto  where id=" & _id

        Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, getConnection)

        cmd.Parameters.Add("@idDitta", _idDitta)
        cmd.Parameters.Add("@nomeDitta", _nomeDitta)
        cmd.Parameters.Add("@dataRichiesta", IIf(_dataRichiesta = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataRichiesta)))
        cmd.Parameters.Add("@dataDel", IIf(_dataDel = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataDel)))
        cmd.Parameters.Add("@numDel", _numDel)
        cmd.Parameters.Add("@stato", _stato)
        cmd.Parameters.Add("@dataInizio", IIf(_dataInizio = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataInizio)))
        cmd.Parameters.Add("@dataFine", IIf(_dataFine = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataFine)))
        cmd.Parameters.Add("@tot", IIf(_tot = "", SqlTypes.SqlInt32.Null, _tot))
        cmd.Parameters.Add("@completato", _completato)
        cmd.Parameters.Add("@crediti", IIf(_crediti = "", SqlTypes.SqlInt32.Null, _crediti))
        cmd.Parameters.Add("@contratto", IIf(_contratto = "", SqlTypes.SqlInt16.Null, _contratto))
        cmd.Parameters.Add("@Utente", System.Security.Principal.WindowsIdentity.GetCurrent.Name)

        cmd.ExecuteNonQuery()
        cmd.Connection.Close()
    End Sub

    Public Sub elimina()
        eseguiSql("delete from attSub where id=" & _id)
    End Sub
End Class

Public Class Prat
    Inherits Connessione

    Private _idPrat As String
    Private _id As String
    Private _idProf As String
    Private _idIsc As String
    Private _idDitta As String
    Private _tipo As String
    Private _nomeProf As String
    Private _cittaProf As String

    Private _dataInizio As String
    Private _dataFine As String
    Private _tot As String
    Private _completato As Boolean
    Private _crediti As String
    Private _contratto As String

    Public Property tot() As String
        Get
            Return _tot
        End Get
        Set(ByVal Value As String)
            _tot = Value
        End Set
    End Property
    Public Property completato() As Boolean
        Get
            Return _completato
        End Get
        Set(ByVal Value As Boolean)
            _completato = Value
        End Set
    End Property
    Public Property crediti() As String
        Get
            Return _crediti
        End Get
        Set(ByVal Value As String)
            _crediti = Value
        End Set
    End Property
    Public Property idPrat() As String
        Get
            Return _idPrat
        End Get
        Set(ByVal Value As String)
            _idPrat = Value
        End Set
    End Property
    Public Property idIsc() As String
        Get
            Return _idIsc
        End Get
        Set(ByVal Value As String)
            _idIsc = Value
        End Set
    End Property
    Public Property id() As String
        Get
            Return _id
        End Get
        Set(ByVal Value As String)
            _id = Value
        End Set
    End Property
    Public Property idProf() As String
        Get
            Return _idProf
        End Get
        Set(ByVal Value As String)
            _idProf = Value
        End Set
    End Property
    Public Property idDitta() As String
        Get
            Return _idDitta
        End Get
        Set(ByVal Value As String)
            _idDitta = Value
        End Set
    End Property
    Public Property tipo() As String
        Get
            Return _tipo
        End Get
        Set(ByVal Value As String)
            _tipo = Value
        End Set
    End Property
    Public Property nomeProf() As String
        Set(ByVal Value As String)
            _nomeProf = Value
        End Set
        Get
            Return _nomeProf
        End Get
    End Property
    Public Property cittaProf() As String
        Get
            Return _cittaProf
        End Get
        Set(ByVal Value As String)
            _cittaProf = Value
        End Set
    End Property
    Public Property contratto() As String
        Get
            Return _contratto
        End Get
        Set(ByVal Value As String)
            _contratto = Value
        End Set
    End Property

    Public Property dataInizio() As String
        Get
            Return _dataInizio
        End Get
        Set(ByVal Value As String)
            _dataInizio = Value
        End Set
    End Property
    Public Property dataFine() As String
        Get
            Return _dataFine
        End Get
        Set(ByVal Value As String)
            _dataFine = Value
        End Set
    End Property

    Public Function calcolaCrediti() As String
        Dim objC As New cConfigura(False)
        Dim totG As Int16 = objC.conf.totalePraticantato
        Dim giorniProf As Int16 = objC.conf.giorniProf
        Dim giorniDitta As Int16 = objC.conf.giorniDitta

        Dim rit As Int16
        _tot = IIf(Trim(_tot) <> "", _tot, 0)

        If _tipo < 2 Then
            'professionista
            'If giorniProf <> totG Then
            rit = (_tot * totG) \ giorniProf
            'End If
        Else
            'ditta
            'If giorniDitta <> totG Then
            rit = (_tot * totG) \ giorniDitta
            'End If
        End If

        If rit <> 0 Then
            Return rit
        Else
            Return ""
        End If

    End Function

    Public Sub carica()
        Dim sql As String
        sql = "SELECT  PratProf.id,PratProf.id_prof, pratprof.id_isc, PratProf.nomeProf, PratProf.CittaProf, " & _
                "convert(char(10),PratProf.Data_inizio, 103) as data_inizio, " & _
                "convert(char(10),PratProf.Data_fine, 103) as Data_fine, " & _
                "PratProf.contratto, tot, completato, crediti FROM PratProf  where PratProf.id= " & _id

        Dim dr As DataRow = getDataTable(sql).Rows(0)
        _idProf = Utility.sNull(dr("id_prof"))
        _idIsc = Utility.sNull(dr("id_isc"))
        '_idDitta = Utility.sNull(dr("id_ditta"))
        _nomeProf = Utility.sNull(dr("NomeProf"))
        _cittaProf = Utility.sNull(dr("cittaProf"))
        _contratto = Utility.sNull(dr("contratto"))
        _dataInizio = Utility.sNull(dr("data_inizio"))
        _dataFine = Utility.sNull(dr("data_fine"))
        _tot = Utility.sNull(dr("tot"))
        _completato = dr("completato")
        _crediti = Utility.sNull(dr("crediti"))

    End Sub

    Public Sub inserisci()
        Dim sql As String = "insert into pratprof (id_prat, id_prof, id_isc, nomeprof, cittaProf,  tipo, contratto,  data_inizio, data_fine, tot, completato, crediti) values(" & _
            "@idprat, @idProf, @idIsc, @nomeProf, @cittaProf, @tipo, @contratto, @dataInizio, @dataFine, @tot, @completato, @crediti)"
        Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, getConnection)

        cmd.Parameters.Add("@idPrat", _idPrat)
        cmd.Parameters.Add("@idProf", IIf(_idProf = "", SqlTypes.SqlInt16.Null, _idProf))
        cmd.Parameters.Add("@idIsc", IIf(_idIsc = "", SqlTypes.SqlInt16.Null, _idIsc))
        cmd.Parameters.Add("@nomeProf", _nomeProf)
        cmd.Parameters.Add("@cittaProf", _cittaProf)
        'cmd.Parameters.Add("@idDitta", IIf(_idDitta = "", SqlTypes.SqlInt16.Null, _idDitta))
        cmd.Parameters.Add("@tipo", _tipo)
        cmd.Parameters.Add("@contratto", IIf(_contratto = "", SqlTypes.SqlInt16.Null, _contratto))
        cmd.Parameters.Add("@dataInizio", IIf(_dataInizio = "", SqlTypes.SqlDateTime.Null, _dataInizio))
        cmd.Parameters.Add("@dataFine", IIf(_dataFine = "", SqlTypes.SqlDateTime.Null, _dataFine))
        cmd.Parameters.Add("@tot", IIf(_tot = "", SqlTypes.SqlInt32.Null, _tot))
        cmd.Parameters.Add("@completato", _completato)
        cmd.Parameters.Add("@crediti", IIf(_crediti = "", SqlTypes.SqlInt32.Null, _crediti))

        cmd.ExecuteNonQuery()
        cmd.Connection.Close()
    End Sub

    Public Sub aggiorna()
        Dim sql As String = "update pratprof set id_prof=@idProf, id_isc=@idIsc, nomeProf=@nomeProf, cittaProf=@cittaProf, tipo=@tipo, contratto=@contratto, data_inizio=@dataInizio, " & _
            "data_fine = @dataFine, tot=@tot, completato=@completato, crediti=@crediti where id=" & _id
        Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, getConnection)

        cmd.Parameters.Add("@idProf", IIf(_idProf = "", SqlTypes.SqlInt16.Null, _idProf))
        cmd.Parameters.Add("@idIsc", IIf(_idIsc = "", SqlTypes.SqlInt16.Null, _idIsc))
        'cmd.Parameters.Add("@idDitta", IIf(_idDitta = "", SqlTypes.SqlInt16.Null, _idDitta))
        cmd.Parameters.Add("@nomeProf", _nomeProf)
        cmd.Parameters.Add("@cittaProf", _cittaProf)
        cmd.Parameters.Add("@tipo", _tipo)

        cmd.Parameters.Add("@dataInizio", IIf(_dataInizio = "", SqlTypes.SqlDateTime.Null, _dataInizio))
        cmd.Parameters.Add("@dataFine", IIf(_dataFine = "", SqlTypes.SqlDateTime.Null, _dataFine))
        cmd.Parameters.Add("@tot", IIf(_tot = "", SqlTypes.SqlInt32.Null, _tot))
        cmd.Parameters.Add("@completato", _completato)
        cmd.Parameters.Add("@crediti", IIf(_crediti = "", SqlTypes.SqlInt32.Null, _crediti))
        cmd.Parameters.Add("@contratto", IIf(_contratto = "", SqlTypes.SqlInt16.Null, _contratto))
        cmd.ExecuteNonQuery()
        cmd.Connection.Close()
    End Sub

    Public Sub elimina()
        eseguiSql("delete from pratprof where id=" & _id)
    End Sub

End Class

Public Class PFormativo
    Inherits Connessione

    Private _id As String
    Private _idPrat As String
    Private _tipo As String
    Private _presso As String
    'Private _dataInizio As String
    'Private _dataFine As String
    'Private _tot As String
    Private _note As String
    Private _completato As Boolean
    Private _crediti As String


    'Public Property tot() As String
    '    Get
    '        Return _tot
    '    End Get
    '    Set(ByVal Value As String)
    '        _tot = Value
    '    End Set
    'End Property
    Public Property completato() As Boolean
        Get
            Return _completato
        End Get
        Set(ByVal Value As Boolean)
            _completato = Value
        End Set
    End Property
    Public Property crediti() As String
        Get
            Return _crediti
        End Get
        Set(ByVal Value As String)
            _crediti = Value
        End Set
    End Property
    Public Property id() As String
        Get
            Return _id
        End Get
        Set(ByVal Value As String)
            _id = Value
        End Set
    End Property
    Public Property idPrat() As String
        Get
            Return _idPrat
        End Get
        Set(ByVal Value As String)
            _idPrat = Value
        End Set
    End Property
    Public Property tipo() As String
        Get
            Return _tipo
        End Get
        Set(ByVal Value As String)
            _tipo = Value
        End Set
    End Property
    Public Property presso() As String
        Get
            Return _presso
        End Get
        Set(ByVal Value As String)
            _presso = Value
        End Set
    End Property
    Public Property note() As String
        Get
            Return _note
        End Get
        Set(ByVal Value As String)
            _note = Value
        End Set
    End Property
    'Public Property dataInizio() As String
    '    Get
    '        Return _dataInizio
    '    End Get
    '    Set(ByVal Value As String)
    '        _dataInizio = Value
    '    End Set
    'End Property
    'Public Property dataFine() As String
    '    Get
    '        Return _dataFine
    '    End Get
    '    Set(ByVal Value As String)
    '        _dataFine = Value
    '    End Set
    'End Property

    Public Sub carica()
        'Dim dr As DataRow = getDataTable("select tipocorso ,presso,ltrim(str(day(dataInizio))) + '/' + ltrim(str(month(dataInizio))) + '/' + ltrim(str(year(dataInizio))) as dataInizio,ltrim(str(day(dataFine))) + '/' + ltrim(str(month(dataFine))) + '/' + ltrim(str(year(dataFine))) as dataFine, tot, completato, crediti from percorsoForm where id =" & _id).Rows(0)
        Dim dr As DataRow = getDataTable("select tipocorso ,presso,note, completato, crediti from percorsoForm where id =" & _id).Rows(0)
        _tipo = dr("tipoCorso")
        _presso = dr("presso")
        '_dataInizio = Utility.sNull(dr("dataInizio"))
        '_dataFine = Utility.sNull(dr("dataFine"))
        '_tot = Utility.sNull(dr("tot"))
        _note = Utility.sNull(dr("note"))
        _completato = dr("completato")
        _crediti = Utility.sNull(dr("crediti"))

    End Sub

    Public Sub inserisci()
        Dim sql As String = " insert into percorsoForm (id_prat, tipocorso, presso, note, completato, crediti, utente) values (" & _
                            "@idPrat, @tipo, @presso, @note, @completato, @crediti, @utente)"

        Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, getConnection)

        cmd.Parameters.Add("@idPrat", _idPrat)
        cmd.Parameters.Add("@presso", _presso)
        cmd.Parameters.Add("@tipo", _tipo)
        'cmd.Parameters.Add("@dataInizio", IIf(_dataInizio = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataInizio)))
        'cmd.Parameters.Add("@dataFine", IIf(_dataFine = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataFine)))
        'cmd.Parameters.Add("@tot", IIf(_tot = "", SqlTypes.SqlInt32.Null, _tot))
        cmd.Parameters.Add("@note", _note)
        cmd.Parameters.Add("@completato", _completato)
        cmd.Parameters.Add("@crediti", IIf(_crediti = "", SqlTypes.SqlInt32.Null, _crediti))
        cmd.Parameters.Add("@Utente", System.Security.Principal.WindowsIdentity.GetCurrent.Name)

        cmd.ExecuteNonQuery()
        cmd.Connection.Close()

    End Sub

    Public Sub aggiorna()
        Dim sql As String = " update percorsoForm set tipoCorso =@tipo, presso = @presso, note = @note, " & _
                " completato=@completato, crediti=@crediti, utente=@utente  where id=" & _id

        Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, getConnection)

        cmd.Parameters.Add("@presso", _presso)
        cmd.Parameters.Add("@tipo", _tipo)
        cmd.Parameters.Add("@note", _note)
        'cmd.Parameters.Add("@dataInizio", IIf(_dataInizio = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataInizio)))
        'cmd.Parameters.Add("@dataFine", IIf(_dataFine = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataFine)))
        'cmd.Parameters.Add("@tot", IIf(_tot = "", SqlTypes.SqlInt32.Null, _tot))
        cmd.Parameters.Add("@completato", _completato)
        cmd.Parameters.Add("@crediti", IIf(_crediti = "", SqlTypes.SqlInt32.Null, _crediti))
        cmd.Parameters.Add("@Utente", System.Security.Principal.WindowsIdentity.GetCurrent.Name)

        cmd.ExecuteNonQuery()
        cmd.Connection.Close()
    End Sub

    Public Sub elimina()
        eseguiSql("delete from percorsoForm where id=" & _id)
    End Sub


End Class


Public Class Abilitazione
    Inherits Connessione

    Private _idPrat As String
    Private _dataDel As String
    Private _numDel As String
    Private _dataAb As String
    Private _motivoAb As String


    Public Property idPrat() As String
        Get
            Return _idPrat
        End Get
        Set(ByVal Value As String)
            _idPrat = Value
        End Set
    End Property
    Public Property dataDel() As String
        Get
            Return _dataDel
        End Get
        Set(ByVal Value As String)
            _dataDel = Value
        End Set
    End Property
    Public Property numDel() As String
        Get
            Return _numDel
        End Get
        Set(ByVal Value As String)
            _numDel = Value
        End Set
    End Property
    Public Property dataAb() As String
        Get
            Return _dataAb
        End Get
        Set(ByVal Value As String)
            _dataAb = Value
        End Set
    End Property
    Public Property motivoAb() As String
        Get
            Return _motivoAb
        End Get
        Set(ByVal Value As String)
            _motivoAb = Value
        End Set
    End Property

    Public Sub carica()
        Dim dt As DataTable = getDataTable("select convert(char(10),dataDel,103) as dataDel, numDel, convert(char(10),dataAb,103) as dataAb, motivoAb from abilitazioni where id_prat=" & _idPrat)
        If dt.Rows.Count > 0 Then
            Dim dr As DataRow = dt.Rows(0)
            _numDel = dr("numdel")
            _dataDel = Utility.sNull(dr("dataDel"))
            _dataAb = Utility.sNull(dr("dataAb"))
            _motivoAb = Utility.sNull(dr("motivoAb"))
        End If

    End Sub

    Public Sub salva()
        eseguiSql("delete from abilitazioni where id_Prat = " & _idPrat)

        Dim sql As String = "insert into abilitazioni (id_prat, dataDel, numDel, dataAb, motivoAb) values (@idPrat, @dataDel, @numDel, @dataAb, @motivoAb) "

        Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, getConnection)
        cmd.Parameters.Add("@idPrat", _idPrat)
        cmd.Parameters.Add("@dataDel", IIf(_dataDel = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataDel)))
        cmd.Parameters.Add("@numDel", _numDel)
        cmd.Parameters.Add("@dataAb", IIf(_dataAb = "", SqlTypes.SqlDateTime.Null, Utility.FormattaDataxDB(_dataAb)))
        cmd.Parameters.Add("@motivoAb", IIf(_motivoAb = "", SqlTypes.SqlInt16.Null, _motivoAb))

        cmd.ExecuteNonQuery()
        cmd.Connection.Close()
    End Sub

End Class

Public Class Esame
    Inherits Connessione

    Private _id As String
    Private _anno As String
    Private _num As String
    Private _dataScritto As String
    Private _dataOrale As String
    Private _presso As String

    Public Property id() As String
        Get
            Return _id
        End Get
        Set(ByVal Value As String)
            _id = Value
        End Set
    End Property
    Public Property anno() As String
        Get
            Return _anno
        End Get
        Set(ByVal Value As String)
            _anno = Value
        End Set
    End Property
    Public Property num() As String
        Get
            Return _num
        End Get
        Set(ByVal Value As String)
            _num = Value
        End Set
    End Property
    Public Property dataScritto() As String
        Get
            Return _dataScritto
        End Get
        Set(ByVal Value As String)
            _dataScritto = Value
        End Set
    End Property
    Public Property dataOrale() As String
        Get
            Return _dataOrale
        End Get
        Set(ByVal Value As String)
            _dataOrale = Value
        End Set
    End Property
    Public Property presso() As String
        Get
            Return _presso
        End Get
        Set(ByVal Value As String)
            _presso = Value
        End Set
    End Property

    Public Sub carica()
        Dim dr As DataRow = getDataTable("SELECT  convert(char(10),Data_scritto,103) as Data_scritto,  convert(char(10),Data_orale,103) as Data_orale, Anno, Num_sessione, Presso FROM EsamiStato where id=" & _id).Rows(0)
        _dataScritto = Utility.sNull(dr("data_scritto"))
        _dataOrale = Utility.sNull(dr("data_orale"))
        _anno = Utility.sNull(dr("anno"))
        _num = dr("num_sessione")
        _presso = Utility.sNull(dr("presso"))
    End Sub

    Public Sub elimina()
        Dim sql As String = "update esamiStato set eliminato=1 where id=" & _id
        eseguiSql(sql)
    End Sub

    Public Sub salva()
        If _id = "" Then
            inserisci()
        Else
            aggiorna()
        End If
    End Sub

    Private Sub inserisci()
        Dim sql As String = "insert into esamiStato ( anno, num_sessione, data_scritto, data_orale, presso) values " & _
            " ( @anno, @num, @dataScritto, @dataOrale, @presso)"
        Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, getConnection)
        cmd.Parameters.Add("@anno", IIf(_anno = "", SqlTypes.SqlInt16.Null, _anno))
        cmd.Parameters.Add("@num", _num)
        cmd.Parameters.Add("@dataScritto", IIf(_dataScritto = "", SqlTypes.SqlDateTime.Null, _dataScritto))
        cmd.Parameters.Add("@dataOrale", IIf(_dataOrale = "", SqlTypes.SqlDateTime.Null, _dataOrale))
        cmd.Parameters.Add("@presso", IIf(_presso = "", SqlTypes.SqlInt16.Null, _presso))

        cmd.ExecuteNonQuery()
        cmd.Connection.Close()
    End Sub

    Private Sub aggiorna()
        Dim sql As String = "update esamiStato set anno=@anno, num_sessione=@num, data_scritto=@dataScritto, data_orale=@dataOrale, " & _
            " presso=@presso  where id=" & _id
        Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, getConnection)
        cmd.Parameters.Add("@anno", IIf(_anno = "", SqlTypes.SqlInt16.Null, _anno))
        cmd.Parameters.Add("@num", _num)
        cmd.Parameters.Add("@dataScritto", IIf(_dataScritto = "", SqlTypes.SqlDateTime.Null, _dataScritto))
        cmd.Parameters.Add("@dataOrale", IIf(_dataOrale = "", SqlTypes.SqlDateTime.Null, _dataOrale))
        cmd.Parameters.Add("@presso", IIf(_presso = "", SqlTypes.SqlInt16.Null, _presso))

        cmd.ExecuteNonQuery()
        cmd.Connection.Close()
    End Sub

    ''Public Sub elimina()
    ''    eseguiSql("delete from esamistato where id=" & _id)
    ''End Sub

End Class

Public Class EsitoEsame
    Inherits Connessione

    Private _id As String
    Private _idPrat As String
    Private _idEsame As String
    Private _esito As String

    Public Property id() As String
        Get
            Return _id
        End Get
        Set(ByVal Value As String)
            _id = Value
        End Set
    End Property
    Public Property idPrat() As String
        Get
            Return _idPrat
        End Get
        Set(ByVal Value As String)
            _idPrat = Value
        End Set
    End Property
    Public Property idEsame() As String
        Get
            Return _idEsame
        End Get
        Set(ByVal Value As String)
            _idEsame = Value
        End Set
    End Property
    Public Property esito() As String
        Get
            Return _esito
        End Get
        Set(ByVal Value As String)
            _esito = Value
        End Set
    End Property

    Public Sub carica()
        Dim sql As String = "select * from esitoEsami where id =  " & id
        Dim dr As DataRow = getDataTable(sql).Rows(0)
        _idEsame = dr("id_Esame")
        _esito = dr("esito")
    End Sub

    Public Sub salva()
        If _id = "" Then
            inserisci()
        Else
            aggiorna()
        End If
    End Sub

    Private Sub inserisci()
        Dim sql As String = "insert into esitoEsami (Id_prat, Id_esame, Esito, Utente) values (@idPrat, @idEsame, @esito, @utente)"

        Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, getConnection)
        cmd.Parameters.Add("@idPrat", _idPrat)
        cmd.Parameters.Add("@idEsame", _idEsame)
        cmd.Parameters.Add("@esito", _esito)
        cmd.Parameters.Add("@utente", System.Security.Principal.WindowsIdentity.GetCurrent.Name)

        cmd.ExecuteNonQuery()
        cmd.Connection.Close()
    End Sub

    Private Sub aggiorna()
        Dim sql As String = "update esitoEsami set Id_esame=@idEsame, Esito=@esito, Utente=@utente where id=" & _id

        Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, getConnection)
        cmd.Parameters.Add("@idEsame", _idEsame)
        cmd.Parameters.Add("@esito", _esito)
        cmd.Parameters.Add("@utente", System.Security.Principal.WindowsIdentity.GetCurrent.Name)

        cmd.ExecuteNonQuery()
        cmd.Connection.Close()
    End Sub

    Public Sub elimina()
        eseguiSql("delete from esitoEsami where id=" & _id)
    End Sub

End Class